<template>
	<view>
		<uni-forms ref="form" :modelValue="formData" :rules="rules">
			<uni-forms-item label="用户名" name="username">
				<uni-easyinput type="text" v-model="formData.username" placeholder="请输入用户名" />
			</uni-forms-item>
			<uni-forms-item label="密码" name="password">
				<input class="input" v-model="formData.password" type="password" 
				placeholder="请输入密码"/>
			</uni-forms-item>
		</uni-forms>
		<button @click="submitLogin(formData)">登录</button>
	</view>
</template>

<script setup>
import {ref} from 'vue'
import {login} from "@/api/login.js" 

const formData = ref({
	"username":"",
	"password":""
})

const submitLogin =async () =>{
	let res =await login(formData.value)
	uni.setStorageSync("token",res.data)
	if(res.code==200){
		uni.switchTab({
			url:"/pages/index/index"
		})
	}
	console.log(res)
}


</script>

<style>

</style>